<?php

namespace App\Services\Member;

use App\Models\Activity\Activity;
use App\Models\Group\Group;
use App\Models\Posts\Posts;
use App\Models\Store\Store;
use App\Models\Vote\Vote;

class ComService
{
    /**
     * 通过资源获取对应的用户uuid
     * @param $place
     * @param $service_uuid
     * @return string
     */
    public static function ServiceMemberUuid($place, $service_uuid){
        try {
            switch ((int)$place){
                case 1:  //新闻
                    $service_member_uuid = '';
                    break;
                case 2:  //投票
                    $row = Vote::where('uuid', $service_uuid)->first();
                    $service_member_uuid = $row->member_uuid;
                    break;
                case 3:  //投票
                    $row = Activity::where('uuid', $service_uuid)->first();
                    $service_member_uuid = $row->member_uuid;
                    break;
                case 4:  //店铺
                    $row = Store::where('uuid', $service_uuid)->first();
                    $service_member_uuid = $row->member_uuid;
                    break;
                case 5:  //推文
                    $row = Posts::where('uuid', $service_uuid)->first();
                    $service_member_uuid = $row->member_uuid;
                    break;
                case 6:  //用户
                    $service_member_uuid = $service_uuid;
                    break;
                case 7:  //talking
                    $row = Group::where('uuid', $service_uuid)->first();
                    $service_member_uuid = $row->member_uuid;
                    break;
                case 8:  //个人邀请函成功分享
                    $service_member_uuid = $service_uuid;
                default:
                    $service_member_uuid = '';
                    break;
            }
        }catch (\Exception $e){
            $service_member_uuid = '';
        }

        return $service_member_uuid;
    }

}
